package com.vtb.base;

import com.vtb.dao.impl.OtDaoImpl;
import com.vtb.dao.impl.QqDaoImpl;
import com.vtb.dao.impl.RrDaoImpl;
import com.vtb.dao.impl.SsDaoImpl;
import com.vtb.entity.Var;
import com.vtb.inter.VtbDaoInterface;

/**
 * Dao 工厂类
 *
 * @author Chen Tao
 * @date 2012-7-1 下午05:32:54
 */
public class VtbDaoFactory {
    
    private static RrDaoImpl rrDao = new RrDaoImpl();
    
    private static QqDaoImpl qqDao = new QqDaoImpl();
    
    private static OtDaoImpl otDao = new OtDaoImpl();
    
    private static SsDaoImpl ssDao = new SsDaoImpl();
    
    private static VtbDaoFactory daoFactory = null;
    
    private VtbDaoFactory(){}
    
    public static VtbDaoFactory getInstance(){
        if (daoFactory == null) {
            synchronized (daoFactory) {
                if (daoFactory == null) {
                    daoFactory = new VtbDaoFactory();
                }
            }
        }
        return daoFactory;
    }
    
    @SuppressWarnings("rawtypes")
    public  VtbDaoInterface getDao(String name){
        if (Var.RRDAO.equals(name)) {
            return rrDao;
        }
        if (Var.QQDAO.equals(name)) {
            return qqDao;
        }
        if (Var.OTDAO.equals(name)) {
            return otDao;
        }
        if (Var.SSDAO.equals(name)) {
            return ssDao;
        }
        return null;
    }
    
}
